#include<iostream>
#include<algorithm>
using namespace std;

const int N=1e5+10;
long long scor[N];
long long scho[N];
int main()
{
	int m,n;cin>>m>>n;
	for(int i=1;i<=m;i++) cin>>scho[i];
	for(int i=1;i<=n;i++) cin>>scor[i];
	sort(scho+1,scho+1+m);
	long long ret=0;
	for(int i=1;i<=n;i++)
	{
		auto left=lower_bound(scho+1,scho+1+m,scor[i]);
		if(left==scho+1+m)
		{
			left-=1;
			ret+=abs(scho[m] - scor[i]);
		}
		else if(left==scho+1)
		{
			ret+=abs(*left-scor[i]);
		}
		else
		{
			ret+=min(llabs(*left-scor[i]),abs(*(left-1)-scor[i]));
		}
	}
	cout<<ret<<endl;
}